package leetcode_1001_1100;

import java.util.ArrayList;
import java.util.List;
import java.util.Queue;

public class LeeCode_1023 {
    public static void main(String[] args) {
        System.out.println(check("FooBar", "FB"));
    }
    private static List<Boolean> camelMatch(String[] queries, String pattern) {
        List<Boolean> ans = new ArrayList<>();
        for (String query : queries) {
            ans.add(check(query, pattern));
        }
        return ans;
    }
    private static boolean check(String s, String p){
        int len = s.length();
        int index = 0;
        char goal = p.charAt(index);
        boolean flag = true;
        for (int i = 0; i < len; i++) {
            char c = s.charAt(i);
            if (c >= 'A' && c <= 'Z' && (c != goal || !flag)){
                return false;
            }
            if (flag && c == goal){
                index++;
                if (index >= p.length()){
                    flag = false;
                }
                if (flag){
                    goal = p.charAt(index);
                }

            }
        }
        return index >= p.length();
    }
}
